# 从键盘输入5个同学的账号和密码,然后将他们的姓名,账号和密码(密码需要加密)保存到一个文件中

import hashlib

students = []

for i in range( 5 ):
    name = input( '请输入学生姓名: ' )
    authority = input( '请输入学生账号: ' )
    password = input( '请输入学生密码: ' )
    student = [ name, authority, password ]
    students.append( student )

with open( 'C:\\Users\\wbw\\Desktop\\Whhpython\\homework4\\studentjiami.txt', 'w' ) as f:
    f.write( 'name\tauthority\tpassword\n' )
    for student in students:
        f.write( student[0] + '\t' + student[1] + '\t\t' )
        md5 = hashlib.md5()
        md5.update( student[2].encode( 'utf-8' ) )
        f.write( md5.hexdigest() )
        f.write( '\n' )